#if !defined(GAMEUPDATESERVERMANAGER_H)
#define GAMEUPDATESERVERMANAGER_H

#include <winsock2.h>
#include <ws2tcpip.h>
#include <wspiapi.h>
#include "../Release/udt.h"

#include "CommFunc.h"
#pragma once 
 
class AFX_EXT_CLASS  CGameUpdateServerManager
{
public:
	CGameUpdateServerManager(void);
	~CGameUpdateServerManager(void);
	static	CGameUpdateServerManager* CreateInstance();
	
	inline CString GetLastError()
	{
		return m_strLastError;
	}  
	BOOL m_isRunning;
private: 
	UDTSOCKET m_serv; 
	CString	m_strFileNamePath;
	int		m_iServerPort;
	CString	m_strLastError;  
	static CGameUpdateServerManager* m_pInstance;
	BOOL CreateUDTSocket(); 
	static DWORD WINAPI StartAccept(void* pParam);
	static DWORD WINAPI SendDownLoadFile(void* pParam);
	CString m_strAppBasePath;
public:
	void InitParams(CString strFileNamePath, int iServerPort);
	BOOL StartServer();
};

#endif